<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link rel="stylesheet" type="text/css" href="css/base.css"/>
		<link rel="stylesheet" type="text/css" href="css/denglu.css"/>
		<script src="js/rem.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/api.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/jquery-1.11.3.min.js"></script>
	</head>
	<body>
		<div class="container">
			<img src="img/状态栏_黑.png"  class="zhuangtai">
			<img src="img/logo.png" class="logo" >
			<p class="welcome">欢迎登陆ELLESHOP账户</p>
			<form action="" method="" class="forms">
				<div class="send">
					<span>+86</span>
					<input type="text" name="" id="phone_num" value="" placeholder="手机号码"/>
				</div>
				<input type="password" name="" id="psd" value="" placeholder="密码"/>
				
				<button type="button" id="btn">登录</button>
				<span id="tishi">
					
				</span>
			</form>
			<span class="fast">手机快速登录</span>
			<div class="share">
				<a href="" class="weixin"></a>
				<a href="" class="qq"></a>
				<a href="" class="weibo"></a>
			</div>
		</div>
		<script type="text/javascript">
			let btn=document.querySelector('#btn')
			let phone_num=document.querySelector('#phone_num')
			let psd=document.querySelector('#psd')
			let tishi=document.querySelector('#tishi')
			let phone_Str=/^(13[0-9]|14[0-9]|15[0-9]|18[0-9]|17[0-9])\d{8}$/
			let pw_Str=/^[a-z0-9A-Z]{6,16}$/
			phone_num.value = localStorage.getItem('phone')
			psd.value = localStorage.getItem('password')
			btn.onclick=function(){
				let phone=phone_num.value;
				let password=psd.value;
				let isPh=false
				if(phone_Str.test(phone_num.value)){
					console.log('符合手机')
					isPh=true
				}else{
					isPh=false;
					console.log('不符合手机')
				}
				let isPw=false
				if(pw_Str.test(psd.value)){
					console.log('密码格式正确')
					isPw=true
				}else{
					console.log('密码格式错误')
					isPw=false
				}
				loginAPI="http://106.13.115.175:8080/elleshop/user/login.do"

				if(phone_Str.test(phone_num.value)&&pw_Str.test(psd.value)){
					$.post(loginAPI,{
						phone,
						password
					},(res)=>{
						console.log(res)
						if(res.code==0){
							alert('登录成功')
							localStorage.setItem('token',res.info)
							location.href='index-jxAll.html'
						}
						
					})
				}
			}
		</script>
	</body>
</html>
